<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>题目上传</title>
    <load href='__PUBLIC__/bower_components/bootstrap/dist/css/bootstrap.min.css' />
    <load href='__PUBLIC__/assets/css/min.css' />
    <load href='__PUBLIC__/jquery-1.10.0.js'/>
    <load href='__PUBLIC__/jquery.validate-1.13.1.js'/>
</head>

<body>
<script>
    $(document).ready(function () {
        $("#form-horizontal").validate({
            errorPlacement: function(error, element) {
                error.appendTo(element.parent().parent().find('.error-msg'));
            },
            rules: {
                title: {
                    required: true,
                    minlength: 1
                },
                content: {
                    required: true,
                    minlength: 1
                }
            },
            messages: {
                title: {
                    required: '*请输入标题',
                    minlength: '*标题不能为空'
                },
                content: {
                    required: '*请输入内容',
                    minlength: '*内容不能为空'
                }
            }
        });
        $("#check").click(function () {
            console.log($("#form-horizontal").valid() ? "填写正确" : "填写不正确");
        });
    });

</script>

<div class="register">
    <h2>上传题目</h2>
    <form class="form-horizontal" id="form-horizontal"  name="exercise-upload"  method="post" >
        <div class="form-group">
            <label class="col-sm-2 control-label">年级</label>
            <div class="col-sm-10">
                <select class="form-control" name="Grade">
                    <option value="六年级">六年级</option>
                    <option value="初一">初一</option>
                    <option value="初二">初二</option>
                    <option value="初三">初三</option>
                    <option value="高一">高一</option>
                    <option value="高二">高二</option>
                    <option value="高三">高三</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">学科</label>
            <div class="col-sm-10">
                <select class="form-control" name="Subject">
                    <option value="语文">语文</option>
                    <option value="数学">数学</option>
                    <option value="英语">英语</option>
                    <option value="政治">政治</option>
                    <option value="历史">历史</option>
                    <option value="物理">物理</option>
                    <option value="生物">生物</option>
                    <option value="化学">化学</option>
                    <option value="地理">地理</option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label  class="col-sm-2 control-label">标题:</label>
            <div class="col-sm-10">
                <input type="text" name="title" id="title" class="form-control" />
            </div>
            <div class="error-msg"></div>
        </div>
        <div class="form-group">
            <label  class="col-sm-2 control-label">内容:</label>
            <div class="col-sm-10">
                <textarea  name="content" id="content" class="ta-exercise" ></textarea>
            </div>
            <div class="error-msg"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" name="submit" id="check" value="1" class="btn btn-default">上传</button>
            </div>
        </div>
    </form>
</div>
</body>
</html>